{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch,random\n",
    "from _code.Utils import recall\n",
    "\n",
    "def acc(src,L):\n",
    "    # src: result directory\n",
    "    # L : total ensembled size\n",
    "    \n",
    "    # loading dataset info\n",
    "    dsets = torch.load(src + 'testdsets.pth')\n",
    "    \n",
    "    # loading feature vectors\n",
    "    R = [torch.load(src+str(d)+'testFvecs.pth') for d in range(L)]\n",
    "    R = torch.cat(R,1)\n",
    "    print(R.size())\n",
    "    \n",
    "    acc_list = recall(R,dsets.idx_to_class,rank=[1,2])\n",
    "\n",
    "    print('R@1:{:.2f} R@2:{:.2f}'.format(acc_list[0].item()*100, acc_list[1].item()*100))\n",
    "    "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
